package com.iretailer.report.analyze.commonUtil;

import com.iretailer.report.util.TimeUtil;

import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;

/**
 * @Auther: xjw
 * @Date: 2019/11/14 0014 20:33
 * @Description:
 */
public class CommonUtil {

    public static boolean  judgeBusinessTime(ZonedDateTime time, ZoneId timeZone, String startTime, String endTime) {
        if (startTime != null && endTime != null) {
            ZonedDateTime start = ZonedDateTime.of(time.toLocalDate(), TimeUtil.parse_LocalTime(startTime), timeZone);
            ZonedDateTime end = ZonedDateTime.of(time.toLocalDate(), TimeUtil.parse_LocalTime(endTime), timeZone);
            //  time >=start  time<end
            if (!time.isBefore(start) && time.isBefore(end)) {
                return true;
            }
        }
        return false;
    }
    public static boolean  judgeBusinessTime(LocalDateTime time, LocalTime startTime, LocalTime endTime) {
        if (startTime != null && endTime != null) {
            LocalDateTime start = LocalDateTime.of(time.toLocalDate(), startTime);
            LocalDateTime end = LocalDateTime.of(time.toLocalDate(), endTime);
            //  time >=start  time<end
            if (!time.isBefore(start) && time.isBefore(end)) {
                return true;
            }
        }
        return false;
    }
}
